tools/hv: Make the sample hv_get_dhcp_info script more useful
authorBen Hutchings <benh@debian.org>
Sun, 15 Jun 2025 21:35:52 +0000 (23:35 +0200)
committerSalvatore Bonaccorso <carnil@debian.org>
Thu, 12 Mar 2026 12:28:10 +0000 (13:28 +0100)
commit50f7f74a0c3d1d3532abf936e45c944ade593dc7
treeb1f5f6ff728a8b8643be8b5c4470461f040cec33
parent8d8a9e0fb054ce962f5eb5a9b3453b77c5464dcc
tools/hv: Make the sample hv_get_dhcp_info script more useful

Origin: https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git/commit?id=29c75ddc2d1952528a1195b6ac52054c47c0ee89
Bug-Debian: https://bugs.debian.org/919350

Currently the sample hv_get_dhcp_info script only supports the old Red
Hat network-scripts configuration format and leaves everything else to
downstream distributions.

However, Network Manager and systemd-networkd are available across
many distributions, so it makes more sense to implement support for
them here.

Debian's ifupdown is also used in several distributions that are not
Debian derivatives, so I think it makes sense to implement support for
that here too.

Extend the script to support all of these:

- Add a report function that reports the status based on the result of
  the previous command
- Add a function for each configuration system that checks whether
  that system in use for the given interface, and:
  - If so, checks and reports the DHCP status
  - If not, returns failure
- Call each of those functions, exiting once one of them succeeds,
  with a final fallback to reporting 'Disabled'

The network-scripts check is placed last, because it only checks a
file and not the actual interface state and so is the least reliable
check.

Signed-off-by: Ben Hutchings <benh@debian.org>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name tools-hv-Make-the-sample-hv_get_dhcp_info-script-mor.patch
tools/hv/hv_get_dhcp_info.sh